#!/usr/bin/env node 

DMAX = 1023
B = 3950.0 
RNTC_AT25 = 10.0 
T2 = 273.15 + 25 

function GetRtFromTemp(temp) {
    rt = RNTC_AT25 * Math.pow( 2.718281828459 , (B/(273.15+temp) - B/(T2)) ) ;
    return rt 
}

function GetAdcFromTemp(temp) {
    rt = GetRtFromTemp(temp) ;
    d = DMAX * rt/(10+rt) ;  //10 为分压电阻
    return Math.ceil(d) 
}

cnt = 0 
line = ""
for ( i=20 ; i < 50;i=i+0.1) {
    cnt++
    // console.log(GetAdcFromTemp(i))
    line = line  + GetAdcFromTemp(i) + ',' 
    if(cnt%10==0) {
        console.log(line)
        line = ""
    } 
    
}

